package com.blog.interceptor.init;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * 1.将客户端加密 后请求的url转换为正确的路径。
 * 2、将GET传输过来的密文值转换为明文。
 * @author Administrator
 *
 */
public class UrlConversion extends HandlerInterceptorAdapter{
	private final Logger log = Logger.getLogger(UrlConversion.class);
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		// TODO 自动生成的方法存根
		String requestUrl = request.getRequestURI();
		String servletName = request.getServerName();
		String servletPath = request.getServletPath();
		log.info("客户端请求的路径为："+requestUrl);
		log.info("服务器地址："+servletName);
		log.info("访问的相对路径为："+servletPath);
		return super.preHandle(request, response, handler);
	}

	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		// TODO 自动生成的方法存根
		super.postHandle(request, response, handler, modelAndView);
	}

	@Override
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		// TODO 自动生成的方法存根
		super.afterCompletion(request, response, handler, ex);
	}

	@Override
	public void afterConcurrentHandlingStarted(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		// TODO 自动生成的方法存根
		super.afterConcurrentHandlingStarted(request, response, handler);
	}
			
}
